PREFIX         =./lib
LIBNAME        =myclient
APP_NAME       =client

SQLITE_LIB     =./sqlite3/lib
SQLITE_INC     =./sqlite3/include

CFLAGS         += -I ./inc/ -I${SQLITE_INC}
LDFLAGS        += -L${PREFIX} -l${LIBNAME} -L${SQLITE_LIB} -lsqlite3

SRC_MAIN       =./src/main.c
SRC_LIB        =./src/client.c ./src/getdata.c ./src/tempdb.c ./src/logger.c 

all:static_lib run

run:
	gcc ${CFLAGS} ${SRC_MAIN} -o ${APP_NAME} ${LDFLAGS}

static_lib:
	mkdir -p ${PREFIX}
	gcc ${CFLAGS} -c ${SRC_LIB}
	ar -rcs lib${LIBNAME}.a *.o
	mv lib${LIBNAME}.a ${PREFIX}

clean:distclean
	rm -f ${APP_NAME} *.db *.log *.log.bak
	rm -f ${PREFIX}/lib${LIBNAME}.a 
distclean:
	rm -f *.o

